package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.domain.SelfProjectRecord;
import com.blrs.service.project.self.ISelfProjectRecordService;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 自建项目履历Controller
 * 
 * @author wangchao
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/self/record")
public class SelfProjectRecordController extends BaseController
{
    @Autowired
    private ISelfProjectRecordService selfProjectRecordService;

    /**
     * 查询自建项目履历列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SelfProjectRecord selfProjectRecord)
    {
        startPage();
        List<SelfProjectRecord> list = selfProjectRecordService.selectSelfProjectRecordList(selfProjectRecord);
        return getDataTable(list);
    }

    /**
     * 导出自建项目履历列表
     */
    @Log(title = "自建项目履历", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SelfProjectRecord selfProjectRecord)
    {
        List<SelfProjectRecord> list = selfProjectRecordService.selectSelfProjectRecordList(selfProjectRecord);
        ExcelUtil<SelfProjectRecord> util = new ExcelUtil<SelfProjectRecord>(SelfProjectRecord.class);
        util.exportExcel(response, list, "自建项目履历数据");
    }

    /**
     * 获取自建项目履历详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(selfProjectRecordService.selectSelfProjectRecordById(id));
    }

    /**
     * 新增自建项目履历
     */
    @Log(title = "自建项目履历", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SelfProjectRecord selfProjectRecord)
    {
        return toAjax(selfProjectRecordService.insertSelfProjectRecord(selfProjectRecord));
    }

    /**
     * 修改自建项目履历
     */
    @Log(title = "自建项目履历", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SelfProjectRecord selfProjectRecord)
    {
        return toAjax(selfProjectRecordService.updateSelfProjectRecord(selfProjectRecord));
    }

    /**
     * 删除自建项目履历
     */
    @Log(title = "自建项目履历", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(selfProjectRecordService.deleteSelfProjectRecordByIds(ids));
    }
}
